package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjmonitor;
import com.chezhujie.www.persistence.CzjmonitorMapper;
import com.xy.core.page.Pagination;
import com.xy.core.utils.UUIDUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by 汤伟杰 on 2017/4/28.
 */
@Service
public class CzjmonitorService {

    @Autowired
    private CzjmonitorMapper czjmonitorMapper;

	public void svseCzjmonitor(Czjmonitor czjmonitor) {
		if(StringUtils.isBlank(czjmonitor.getMonitorId())){
			czjmonitor.setMonitorId(UUIDUtils.getUUID());
		}
		czjmonitorMapper.svseCzjmonitor(czjmonitor);
	}

	public List<Czjmonitor> listCzjmonitor(Map<String, Object> map) {
		return czjmonitorMapper.listCzjmonitor(map);
	}

	public Pagination listmon(Map<String, Object> map, Integer pageSize,
							  Integer pageNo) {
		
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		map.putAll(p.toMap());
		int count=czjmonitorMapper.getTotalListmon(map);
		List<Czjmonitor> list=	czjmonitorMapper.getListmon(map);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
	}






}
